package list;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by SliverZhang on 2017/11/19.
 */
public class Book {
    private String title;
    private double price;

    public Book(String title, double price) {
        this.title = title;
        this.price = price;
    }

    @Override
    public boolean equals(Object obj) {
        if (this==obj){
            return true;
        }
        if (obj == null){
            return false;
        }
        if (!(obj instanceof Book)){
            return false;
        }
        Book book = (Book) obj;
        if (this.title.equals(book.title) && this.price==book.price){
            return true;
        }
        return false;
    }

    @Override
    public String toString() {
        return "Book{" +
                "title='" + title + '\'' +
                ", price=" + price +
                '}';
    }

}

class TestDemo{
    public static void main(String[] args) {
        List<Book> all = new ArrayList<>();
        all.add(new Book("AA",45));
        all.add(new Book("BB",55));
        all.add(new Book("CC",65));
        all.remove(new Book("AA",45));
        System.out.println(all);
    }
}